import time

from selenium.webdriver.common.by import By
from selenium import webdriver
from Pozk0903.Base import Base

class Page(Base):
    #点击去登录
    login_loc=(By.CLASS_NAME,'headerLogin')
    def login(self):
        self.click(self.login_loc)
    #断言
    dy_loc=(By.XPATH,'/html/body/div/form/div/div/div/div/div[1]/div[1]/a[1]')
    def dy1(self):
        self.text(self.dy_loc)
    #输入账号密码
    user_loc=(By.NAME,'uname')
    def username(self):
        self.send_keys(self.user_loc,'13381144084')
    pass_loc=(By.ID,'password')
    def password(self):
        self.send_keys(self.pass_loc,'grq200566++')
    #点击登录按钮
    an_loc=(By.ID,'save')
    def anniu(self):
        self.click(self.an_loc)
    #点击输入框输入内容
    srk_loc=(By.ID,'wd')
    def srk(self):
        self.send_keys(self.srk_loc,'五粮液')
    #点击搜索按钮
    ss_loc=(By.XPATH,'/html/body/div[4]/div/div[2]/div[1]/form/input[2]')
    def ss(self):
        self.click(self.ss_loc)
    #点击商品
    sp_loc=(By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img')
    def sp(self):
        self.click(self.sp_loc)
    #点击购物车
    gwc_loc=(By.ID,'addToCartForDetail')
    def gwc(self):
        self.click(self.gwc_loc)

    def jiuxian_luoji_gwc(self):
        self.open_url('https://www.jiuxian.com/')
        time.sleep(5)
        self.login()
        self.username()
        self.password()
        time.sleep(15)
        self.anniu()
        self.driver.implicitly_wait(10)
        self.srk()
        self.ss()
        time.sleep(4)
        self.sp()
        self.window()
        self.gwc()
